package com.example.asus.Test;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.asus.mydiary.R;

import java.util.List;

public class DiaryAdapter extends RecyclerView.Adapter<DiaryAdapter.mViewHolder>{
    private List<String> data;

    public DiaryAdapter(List<String> list){
        data = list;
    }

    public class mViewHolder extends RecyclerView.ViewHolder{
        private TextView mTvTitle;
        public mViewHolder(View itemView) {
            super(itemView);
            mTvTitle = (TextView)itemView.findViewById(R.id.item_tv);
        }
    }

    @Override
    public mViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new mViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_rv_item, parent, false));
    }

    @Override
    public void onBindViewHolder(mViewHolder holder, int position) {
        TextView tv = holder.mTvTitle;
        tv.setText(data.get(position));
    }

    @Override
    public int getItemCount() {
        return data == null ? 0 : data.size();
    }
}
